Skip to content

fix(claude-sandbox): close VS Code credential helper leak#338

Merged
gilesknap merged 1 commit intoDiamondLightSource:claude-sandboxfrom
gilesknap:add-claude-sandbox
Apr 29, 2026
Merged

fix(claude-sandbox): close VS Code credential helper leak#338
gilesknap merged 1 commit intoDiamondLightSource:claude-sandboxfrom
gilesknap:add-claude-sandbox

Conversation

@gilesknap
Copy link
Copy Markdown
Contributor

VS Code's Dev Containers extension re-injects a /tmp credential bridge after postStart runs, allowing host GitHub PATs to leak into the container even with VSCODE_GIT_IPC_HANDLE blanked. Fix by:

  • Use --unset-all (not =) for credential.helper, so the multi-valued entry VS Code writes is actually cleared.
  • Remove /tmp/vscode-remote-containers-*.js so the bridge cannot answer even if a stale helper survives.
  • Pin per-host helpers to command -v gh / glab so a stale host path (/usr/local/bin/gh) doesn't fall through to the next helper.
  • Re-run cleanup on postAttachCommand because VS Code injects after postStartCommand has already finished.

Also:

  • Install just explicitly when add_claude (recipes need it)
  • Bump glab to 1.93.0
  • Add CLAUDE.md describing sandbox boundaries and intentional exposures (NFS-mounted ~/.claude, /workspaces parent bind, --net=host)
  • Link CLAUDE.md from README

VS Code's Dev Containers extension re-injects a /tmp credential bridge
after postStart runs, allowing host GitHub PATs to leak into the
container even with VSCODE_GIT_IPC_HANDLE blanked. Fix by:

- Use --unset-all (not =) for credential.helper, so the multi-valued
  entry VS Code writes is actually cleared.
- Remove /tmp/vscode-remote-containers-*.js so the bridge cannot answer
  even if a stale helper survives.
- Pin per-host helpers to command -v gh / glab so a stale host path
  (/usr/local/bin/gh) doesn't fall through to the next helper.
- Re-run cleanup on postAttachCommand because VS Code injects after
  postStartCommand has already finished.

Also:
- Install just explicitly when add_claude (recipes need it)
- Bump glab to 1.93.0
- Add CLAUDE.md describing sandbox boundaries and intentional exposures
  (NFS-mounted ~/.claude, /workspaces parent bind, --net=host)
- Link CLAUDE.md from README
@gilesknap gilesknap merged commit 1189553 into DiamondLightSource:claude-sandbox Apr 29, 2026
3 of 4 checks passed
Comment on lines 89 to 107
}{% if install_gh %},
// Persist gh auth across container rebuilds with per-repo scoped PAT
{
"source": "gh-auth-${localWorkspaceFolderBasename}",
"target": "/root/.config/gh",
"type": "volume"
}{% endif %}{% if install_glab %},
// Persist glab auth across container rebuilds (GitLab CLI)
{
"source": "glab-auth-${localWorkspaceFolderBasename}",
"target": "/root/.config/glab-cli",
"type": "volume"
}{% endif %}{% if add_claude %},
// Mount Claude config from host (settings, memory, skills)
{
"source": "${localEnv:HOME}/.claude",
"target": "/root/.claude",
"type": "bind"
}{% endif %}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could /root/.config come from /user-terminal-config and be shared that way?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants